#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <assert.h>
#include <SDL2/SDL.h>

#include "bsp.h"
#include "parameter.h"

int hal_save_para(char *para_name, int para_val)
{
	char val[64];
	SDL_zero(val);
	snprintf(val, 64, "%d", para_val);
	return save_paramemter_to_flash(para_name, val);
}

int hal_get_para(char *para_name, int *pval)
{
	char retbuf[64];
	SDL_zero(retbuf);
	if(load_paramemter_from_flash(para_name, retbuf, sizeof(retbuf)) > 0) {
		(*pval) = atoi(retbuf);
		return  0;		
	} else {
		return -1;
	}
}